package com.example.springbatch4;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersIncrementer;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 作业时间戳参数 时间作为入参 确保可以记录每天具体执行的时间
 */
@Component(value = "dailyTimestampParamIncrementer")
public class DailyTimestampParamIncrementer implements JobParametersIncrementer {
    @Override
    public JobParameters getNext(JobParameters parameters) {
        return new JobParametersBuilder(parameters)
                .addLong("daily", new Date().getTime())  //获取时间戳
                .toJobParameters();
    }
}
